package cn.cvs.chap4bootmybatis.controller;

import cn.cvs.chap4bootmybatis.dao.EmployeeMapper;
import cn.cvs.chap4bootmybatis.entity.Employee;
import cn.cvs.chap4bootmybatis.service.EmployeeService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
public class EmployeeController {
    @Autowired
    EmployeeService employeeService;
    @GetMapping("/emp/{empno}")
    public String list(@PathVariable Integer empno, Model model){
        Employee employee=employeeService.getEmp(empno);
        model.addAttribute(employee);
        return "employee";
    }
}
